/**
 * 全局样式文件
 * @author cencat
 * @description 固定商家场景多租户SaaS企业综合管理系统全局样式
 * @createTime 2024-01-01
 */

@import './variables.scss';

// ==================== CSS Reset ====================

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: $font-family-primary;
  font-size: $font-size-base;
  font-weight: $font-weight-normal;
  line-height: $line-height-normal;
  color: $text-primary;
  background-color: $bg-primary;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

// ==================== 链接样式 ====================

a {
  color: $primary-color;
  text-decoration: none;
  transition: color $duration-normal $ease-out;
  
  &:hover {
    color: $primary-dark;
  }
  
  &:focus {
    outline: 2px solid $primary-color;
    outline-offset: 2px;
  }
}

// ==================== 按钮样式重置 ====================

button {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  
  &:focus {
    outline: 2px solid $primary-color;
    outline-offset: 2px;
  }
  
  &:disabled {
    cursor: not-allowed;
    opacity: 0.6;
  }
}

// ==================== 表单元素样式 ====================

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  
  &:focus {
    outline: 2px solid $primary-color;
    outline-offset: 2px;
  }
}

// ==================== 图片样式 ====================

img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

// ==================== 表格样式 ====================

table {
  border-collapse: collapse;
  border-spacing: 0;
}

// ==================== 列表样式 ====================

ul,
ol {
  list-style: none;
}

// ==================== 标题样式 ====================

h1, h2, h3, h4, h5, h6 {
  font-weight: $font-weight-semibold;
  line-height: $line-height-tight;
  margin: 0;
}

h1 {
  font-size: $font-size-4xl;
}

h2 {
  font-size: $font-size-3xl;
}

h3 {
  font-size: $font-size-2xl;
}

h4 {
  font-size: $font-size-xl;
}

h5 {
  font-size: $font-size-lg;
}

h6 {
  font-size: $font-size-base;
}

// ==================== 段落样式 ====================

p {
  margin: 0;
  line-height: $line-height-normal;
}

// ==================== 滚动条样式 ====================

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: $gray-100;
  border-radius: $border-radius-sm;
}

::-webkit-scrollbar-thumb {
  background: $gray-400;
  border-radius: $border-radius-sm;
  transition: background $duration-normal $ease-out;
  
  &:hover {
    background: $gray-500;
  }
}

// ==================== 工具类 ====================

// 文本对齐
.text-left {
  text-align: left;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-justify {
  text-align: justify;
}

// 文本颜色
.text-primary {
  color: $text-primary;
}

.text-secondary {
  color: $text-secondary;
}

.text-disabled {
  color: $text-disabled;
}

.text-inverse {
  color: $text-inverse;
}

.text-success {
  color: $success-color;
}

.text-warning {
  color: $warning-color;
}

.text-error {
  color: $error-color;
}

.text-info {
  color: $info-color;
}

// 字体大小
.text-xs {
  font-size: $font-size-xs;
}

.text-sm {
  font-size: $font-size-sm;
}

.text-base {
  font-size: $font-size-base;
}

.text-lg {
  font-size: $font-size-lg;
}

.text-xl {
  font-size: $font-size-xl;
}

.text-2xl {
  font-size: $font-size-2xl;
}

.text-3xl {
  font-size: $font-size-3xl;
}

// 字体粗细
.font-light {
  font-weight: $font-weight-light;
}

.font-normal {
  font-weight: $font-weight-normal;
}

.font-medium {
  font-weight: $font-weight-medium;
}

.font-semibold {
  font-weight: $font-weight-semibold;
}

.font-bold {
  font-weight: $font-weight-bold;
}

// 显示/隐藏
.hidden {
  display: none;
}

.invisible {
  visibility: hidden;
}

.visible {
  visibility: visible;
}

// Flex布局
.flex {
  display: flex;
}

.inline-flex {
  display: inline-flex;
}

.flex-col {
  flex-direction: column;
}

.flex-row {
  flex-direction: row;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-nowrap {
  flex-wrap: nowrap;
}

.items-start {
  align-items: flex-start;
}

.items-center {
  align-items: center;
}

.items-end {
  align-items: flex-end;
}

.items-stretch {
  align-items: stretch;
}

.justify-start {
  justify-content: flex-start;
}

.justify-center {
  justify-content: center;
}

.justify-end {
  justify-content: flex-end;
}

.justify-between {
  justify-content: space-between;
}

.justify-around {
  justify-content: space-around;
}

.justify-evenly {
  justify-content: space-evenly;
}

.flex-1 {
  flex: 1 1 0%;
}

.flex-auto {
  flex: 1 1 auto;
}

.flex-initial {
  flex: 0 1 auto;
}

.flex-none {
  flex: none;
}

// 间距
.m-0 {
  margin: 0;
}

.m-1 {
  margin: $spacing-xs;
}

.m-2 {
  margin: $spacing-sm;
}

.m-3 {
  margin: $spacing-md;
}

.m-4 {
  margin: $spacing-lg;
}

.m-6 {
  margin: $spacing-xl;
}

.m-8 {
  margin: $spacing-2xl;
}

.mt-0 {
  margin-top: 0;
}

.mt-1 {
  margin-top: $spacing-xs;
}

.mt-2 {
  margin-top: $spacing-sm;
}

.mt-3 {
  margin-top: $spacing-md;
}

.mt-4 {
  margin-top: $spacing-lg;
}

.mt-6 {
  margin-top: $spacing-xl;
}

.mt-8 {
  margin-top: $spacing-2xl;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-1 {
  margin-bottom: $spacing-xs;
}

.mb-2 {
  margin-bottom: $spacing-sm;
}

.mb-3 {
  margin-bottom: $spacing-md;
}

.mb-4 {
  margin-bottom: $spacing-lg;
}

.mb-6 {
  margin-bottom: $spacing-xl;
}

.mb-8 {
  margin-bottom: $spacing-2xl;
}

.ml-0 {
  margin-left: 0;
}

.ml-1 {
  margin-left: $spacing-xs;
}

.ml-2 {
  margin-left: $spacing-sm;
}

.ml-3 {
  margin-left: $spacing-md;
}

.ml-4 {
  margin-left: $spacing-lg;
}

.ml-6 {
  margin-left: $spacing-xl;
}

.ml-8 {
  margin-left: $spacing-2xl;
}

.mr-0 {
  margin-right: 0;
}

.mr-1 {
  margin-right: $spacing-xs;
}

.mr-2 {
  margin-right: $spacing-sm;
}

.mr-3 {
  margin-right: $spacing-md;
}

.mr-4 {
  margin-right: $spacing-lg;
}

.mr-6 {
  margin-right: $spacing-xl;
}

.mr-8 {
  margin-right: $spacing-2xl;
}

.p-0 {
  padding: 0;
}

.p-1 {
  padding: $spacing-xs;
}

.p-2 {
  padding: $spacing-sm;
}

.p-3 {
  padding: $spacing-md;
}

.p-4 {
  padding: $spacing-lg;
}

.p-6 {
  padding: $spacing-xl;
}

.p-8 {
  padding: $spacing-2xl;
}

// 宽度
.w-full {
  width: 100%;
}

.w-auto {
  width: auto;
}

.w-fit {
  width: fit-content;
}

// 高度
.h-full {
  height: 100%;
}

.h-auto {
  height: auto;
}

.h-fit {
  height: fit-content;
}

.h-screen {
  height: 100vh;
}

// 圆角
.rounded-none {
  border-radius: 0;
}

.rounded-sm {
  border-radius: $border-radius-sm;
}

.rounded {
  border-radius: $border-radius-md;
}

.rounded-lg {
  border-radius: $border-radius-lg;
}

.rounded-xl {
  border-radius: $border-radius-xl;
}

.rounded-full {
  border-radius: $border-radius-full;
}

// 阴影
.shadow-none {
  box-shadow: none;
}

.shadow-sm {
  box-shadow: $box-shadow-sm;
}

.shadow {
  box-shadow: $box-shadow-md;
}

.shadow-lg {
  box-shadow: $box-shadow-lg;
}

.shadow-xl {
  box-shadow: $box-shadow-xl;
}

// 科幻效果类
.neon-glow {
  box-shadow: $neon-primary;
  transition: box-shadow $duration-normal $ease-out;
}

.glass-effect {
  background: $glass-bg;
  border: 1px solid $glass-border;
  backdrop-filter: $glass-backdrop;
}

.gradient-bg {
  background: $gradient-primary;
}

.gradient-text {
  background: $gradient-primary;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

// 动画类
.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-bounce {
  animation: bounce 1s infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-fade-in {
  animation: fadeIn $duration-normal $ease-out;
}

.animate-slide-up {
  animation: slideUp $duration-normal $ease-out;
}

// 过渡类
.transition-all {
  transition: all $duration-normal $ease-out;
}

.transition-colors {
  transition: color $duration-normal $ease-out, background-color $duration-normal $ease-out, border-color $duration-normal $ease-out;
}

.transition-transform {
  transition: transform $duration-normal $ease-out;
}

// ==================== 动画定义 ====================

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(-25%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

// ==================== 响应式工具类 ====================

@media (max-width: $breakpoint-sm) {
  .sm\:hidden {
    display: none;
  }
  
  .sm\:block {
    display: block;
  }
  
  .sm\:flex {
    display: flex;
  }
}

@media (max-width: $breakpoint-md) {
  .md\:hidden {
    display: none;
  }
  
  .md\:block {
    display: block;
  }
  
  .md\:flex {
    display: flex;
  }
}

@media (max-width: $breakpoint-lg) {
  .lg\:hidden {
    display: none;
  }
  
  .lg\:block {
    display: block;
  }
  
  .lg\:flex {
    display: flex;
  }
}

// ==================== 暗色主题 ====================

.dark {
  color-scheme: dark;
  
  body {
    color: $dark-text-primary;
    background-color: $dark-bg-primary;
  }
  
  .text-primary {
    color: $dark-text-primary;
  }
  
  .text-secondary {
    color: $dark-text-secondary;
  }
  
  .text-disabled {
    color: $dark-text-disabled;
  }
  
  ::-webkit-scrollbar-track {
    background: $dark-bg-tertiary;
  }
  
  ::-webkit-scrollbar-thumb {
    background: $dark-border-medium;
    
    &:hover {
      background: $dark-border-dark;
    }
  }
}